package com.likl.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.likl.domain.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * ClassName:springboot_study
 * Description:
 *
 * @Create: 2024/7/2 11:05
 * @author: likl
 * @e-mail: likl1102@foxmail.com
 * @QQ: 2514927731
 */
@SpringBootTest
public class BookServiceTestCase {
    @Autowired
    private BookService bookService;

    @Test
    void testGetById() {
        System.out.println(bookService.getById(3));
    }

    @Test
    void testSave() {
        Book book = new Book();
        book.setType("musicTest");
        book.setName("musicTest");
        book.setDescription("musicTest");
        bookService.save(book);
    }

    @Test
    void testUpdate() {
        Book book = new Book();
        book.setId(4);
        book.setType("musicTest4");
        book.setName("musicTest4");
        book.setDescription("musicTest4");
        bookService.update(book);
    }

    @Test
    void testDelete() {
        bookService.delete(4);
    }

    @Test
    void testGetAll() {
        System.out.println(bookService.getAll());
    }

    @Test
    void testGetPage() {
        IPage<Book> page = bookService.getPage(2, 2);
        System.out.println(page.getPages());
        System.out.println(page.getCurrent());
        System.out.println(page.getTotal());
        System.out.println(page.getSize());
        System.out.println(page.getRecords());
    }
}
